import { defineStore } from 'pinia';

export const useTitle = defineStore('useTitle', {
  state: () =>
    <{ currentBatchName: string }>{
      currentBatchName: '',
    },
  actions: {},
  getters: {
    getCurrentBatchName(): string {
      if (!this.currentBatchName) return '';
      // 'D:\\Agilent\\ICPMH\\1\\DATA\\2024-3-23.b'.
      //   const arr = this.currentBatchName.match(/(?:.*\/)([^/]+)$/);
      const a = this.currentBatchName.split('\\');
      if (a.length > 0) {
        return a[a.length - 1];
      }
      //   if (arr && arr.length > 0) {
      //     return arr[1];
      //   }
      return '';
    }, // 获取当前批次名称
  },
});
